package jm.nj.day10.demo03;

import java.io.*;

/*
* 使用缓冲流 复制Demo01.java到指定文件
*
* 1.创建 bw br对象
* 2.一边读一边写一边刷新
* 3.关闭
* */
public class Test02 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new FileReader("Demo01.java"));
        BufferedWriter bw = new BufferedWriter(new FileWriter("cp3.txt"));
        int read;
        int read0;
        while((read = br.read()) != -1){
           // bw.write((char)read);//也行
            bw.write(read);
            bw.flush();
        }
       /* char[] chs = new char[1024];
        int len;
        while((len = br.read(chs)) != -1){
           // bw.write(new String(chs,0,len));
            bw.write(chs,0,len);
            bw.flush();
        }*/
        bw.close();
        br.close();

    }
}
